using Partner.Surround.CommonDto;
using Partner.Surround.Controllers;
using Partner.Surround.Web.Models.Common;

namespace Partner.Surround.Web.Controllers
{
    public abstract class SurroundControllerWebBase : SurroundControllerBase
    {
        protected SPagedInput PagedViewModelMapToPagedInputDto<TViewModel, SPagedInput>(TViewModel viewModel)
            where SPagedInput : PagedInputDto
            where TViewModel : PagedViewModel
        {
            var input = ObjectMapper.Map<SPagedInput>(viewModel);
            input.MaxResultCount = viewModel.Limit;
            input.SkipCount = (viewModel.Page - 1) * viewModel.Limit;

            return input;
        }
    }
}
